<?php

namespace App\Http\Controllers\v1;


use App\Models\Area;
use App\Models\Banner;
use App\Models\Family;
use App\Models\GoodExample;
use App\Models\Org;
use App\Models\Project;
use App\Models\SmsCode;
use App\Models\Team;
use App\Models\User;
use App\Models\UserCollection;
use App\Models\UserInterface;
use App\Models\UserMessage;
use App\Models\UserProject;
use App\Models\UserTeam;
use App\Models\Volunteer;
use App\Models\VolunteerGoodAt;
use EasyWeChat\Core\Exception;
use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Http\Request;
use App\Libs\IdCard;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator;
use Hashids\Hashids;
use EasyWeChat\Foundation\Application;


class GoodExampleController extends Controller
{

    public function index(Request $request)
    {
        $nodes = GoodExample::where('status', 1);
        $nodes = $nodes->where('org_id', $this->getOrdId())->orderBy('publish_time', 'desc')->get();

        foreach($nodes as $value)
        {
            $list[] = GoodExample::format($value);
        }
        $data['list'] = $list;
        $this->setData($data);
        return $this->response();
    }

    public function show(Request $request, $id)
    {
        $node = GoodExample::where('status', 1)->where('org_id', $this->getOrdId())->where('id', $id)->first();

        $data = GoodExample::format($node);

        $this->setData($data);

        return $this->response();
    }

}
